package study.day4.t3;

import java.util.Scanner;

public class T3 {
    public static void menu(){
        System.out.println("这是图书系统");
        System.out.println("请选择你的操作");
        System.out.println("1.图书列表");
        System.out.println("2.添加图书");
        System.out.println("0.退出系统");
    }
    public static void main(String[] args) {
        BookManager bookManager=new BookManager();
        //初始化
        bookManager.initBooks();
        menu();
        //输入操作
        Scanner input=new Scanner(System.in);
        int num = input.nextInt();
        while (num!=0){
            if(num==1){
                bookManager.bookList();
                menu();
                num = input.nextInt();
            } else if (num==2) {
                System.out.println("这是图书添加系统");
                Book book=new Book();
                System.out.println("输入书名：");
                book.name=input.next();
                System.out.println("输入作者：");
                book.author=input.next();
                System.out.println("输入价格：");
                book.price=input.nextInt();
                boolean flag=bookManager.addBook(book);
                if(flag){
                    System.out.println("添加成功");
                }else{
                    System.out.println("添加失败");
                }
                menu();
                num = input.nextInt();
            }else if(num==0) break;
        }
        System.out.println("感谢使用该系统！");
    }
}
